﻿<?php
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
if( empty($_GET['groupID']) ){
    $groupID=2;
}else{
  $groupID = $_GET['groupID'];
}
$url = "http://www.laoyou1.me/shhomer/output_pc/SelectLast.php?groupID=$groupID";
$data =  https2_request( $url );
$data = json_decode( $data );

$data= object_array($data);
// print_r( $data );
// if( $data['list'] )
$datas = $data['last'];
// print_r( $datas );
$ex_data = $data['exceptional'];
$did = $datas[0]['did'];
$url = "http://www.laoyou1.me/shhomer/output/GetGateStatus.php?did=$did";
$code =  https2_request( $url );
$code =object_array(json_decode( $code ));
// print_r( $code );
$url = "http://www.laoyou1.me/shhomer/output/Alarmlist_pc.php?did=$did";
$alarmlist =  https2_request( $url );
$alarmlist =object_array(json_decode( $alarmlist ));
function https2_request($url,$data = null){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    if (!empty($data)){
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    }
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($curl);
    curl_close($curl);
    return $output;

}

function object_array($array) {
    if(is_object($array)) {
        $array = (array)$array;
     } if(is_array($array)) {
         foreach($array as $key=>$value) {
             $array[$key] = object_array($value);
             }
     }
     return $array;
}
?>
